package com.yyi.springcloud.service.impl;


import com.yyi.springcloud.dao.TestProdInfoItemMapper;
import com.yyi.springcloud.entities.TestProdInfoItemModel;
import com.yyi.springcloud.service.Local_TestProdInfoItemService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.List;

@Service
public class Local_TestProdInfoItemImpl implements Local_TestProdInfoItemService {
	@Resource
	private TestProdInfoItemMapper testProdInfoItemMapper;

	public TestProdInfoItemMapper getTestProdInfoItemMapper() {
		return testProdInfoItemMapper;
	}

	public void setTestProdInfoItemMapper(TestProdInfoItemMapper testProdInfoItemMapper) {
		this.testProdInfoItemMapper = testProdInfoItemMapper;
	}

	@Override
	public List<TestProdInfoItemModel> getTestProdInfoItemByCondition(TestProdInfoItemModel testProdInfoItemModel) {
		Example example = new Example(TestProdInfoItemModel.class);
		Example.Criteria criteria = example.createCriteria();
		if (testProdInfoItemModel != null && !StringUtils.isEmpty(testProdInfoItemModel.getLabcode())) {
			criteria.andEqualTo("labcode", testProdInfoItemModel.getLabcode());
		}
		// 根据录入条目号排序
		example.setOrderByClause("itemno");
		List<TestProdInfoItemModel> testProdInfoItemList = testProdInfoItemMapper.selectByExample(example);
		return testProdInfoItemList;

	}

	@Override
	public List<TestProdInfoItemModel> listTestProdInfoItems() {
		Example example = new Example(TestProdInfoItemModel.class);
		example.setOrderByClause("ITEMNO ASC");
		return testProdInfoItemMapper.selectByExample(example);
	}
}
